<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-susdRule-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">计算方式：</label>
				<div class="col-sm-8">
					<select id="surType" class="form-control m-b" th:with="type=${@dict.getType('pm_sur_type')}">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">补助金额：</label>
				<div class="col-sm-8">
					<input id="surPrice" name="surPrice" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">补助类型：</label>
				<div class="col-sm-8">
					<select id="sudeType" class="form-control m-b" th:with="type=${@dict.getType('pm_susd_type')}">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">日期类型：</label>
				<div class="col-sm-8">
					<select id="wdDtType" class="form-control m-b" th:with="type=${@dict.getType('pm_date_type')}">
						<option value="">请选择...</option>
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">人员级别：</label>
				<div class="col-sm-8">
					<select id="wlLevel" class="form-control m-b" th:with="type=${@dict.getType('pm_emp_level')}">
						<option value="">请选择...</option>
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">规则说明：</label>
				<div class="col-sm-8">
					<textarea id="surNote" name="surNote" class="form-control" type="text" placeholder="请输入文本" rows="10"></textarea>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "pm/susdRule";
		$("#form-susdRule-add").validate({
			rules:{
				surType:{
					required:true,
				},
				sudeType:{
					required:true,
				},
				surPrice:{
					required:true,
				}
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	add();
	        }
	    }
		
		function add() {
        	var surType = $("#surType option:selected").val();
        	var sudeType = $("#sudeType option:selected").val();
        	var wdDtType = $("#wdDtType option:selected").val();
        	var wlLevel = $("#wlLevel option:selected").val();
        	var surPrice = $("input[name='surPrice']").val();
        	var surNote = $("textarea[name='surNote']").val();
        	$.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "pm/susdRule/add",
        		data : {
        			"surType": surType,
        			"sudeType": sudeType,
        			"wdDtType": wdDtType,
        			"wlLevel": wlLevel,
        			"surPrice": surPrice,
        			"surNote": surNote
        		},
        		async : true,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        			$.operate.saveSuccess(data);
        		}
        	});
        }
	</script>
</body>
</html>
